package fem2;


/**
 * 
 * The <code>Force</code> represents forces on nodes in a Finite Element Model.
 * 
 * @author Matthias Baitsch, Kiendung Nguyen
 */

public class Force extends Load {

	private double[] f;

	/**
	 * constructor for static load
	 * 
	 * @param n
	 *            node
	 * @param f
	 *            force
	 */
	public Force(Node n, double... f) {
		super(n);
		if (f.length != n.countFields()) {
			Debugger.error("number of loads on node must be equal to number of fields");
		}
		this.f = f;
	}

	public double getValue(int idx) {
		return this.f[idx];
	}

	public double[] getValues() {
		return this.f;
	}

	public Node getNode() {
		return (Node) getMeshPart();
	}

	@Override
	public double[] computeRe(double t) {
		double[] gV = new double[this.f.length];
		for (int i = 0; i < this.f.length; i++) {
			gV[i] = lambda.valueAt(t) * getValue(i);
		}
		return gV;
	}

}
